<%@ taglib uri="/WEB-INF/webflow.tld" prefix="webflow" %>
<%@ taglib uri="/WEB-INF/webform.tld" prefix="webform" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>


<%@ page import="com.broadvision.ssp.common.SSContext,
                 com.broadvision.data.cache.DataCache" %>
<%@ page import="com.broadvision.ssp.webflow.WebflowHelper" %>
<%@ page import="com.broadvision.data.common.TableData" %>
<%@ page import="com.broadvision.data.client.DataManager" %>
<%@ page import="com.broadvision.data.client.DataCacheUtil" %>
<%@ page import="java.util.ArrayList" %>

<%@page import="com.broadvision.ssp.webflow.taglib.*" %>
<script LANGUAGE="JavaScript" src='<%= response.encodeURL(EncodeTag.encodeURL(request.getContextPath() + "/formJsp/validation.js", request)) %>'></script>
<script LANGUAGE="JavaScript" src='<%= response.encodeURL(EncodeTag.encodeURL(request.getContextPath() + "/formJsp/pageflow_utils.js", request)) %>'></script>

<script language="JavaScript">
var _has_cancel_event = true;
</script>

<webflow:advance event='next' id='next' />
<webflow:advance event='cancel' id='cancel' />

<script language="JavaScript">

  function next(url) {
    window.open(url, "_self");
  }

</script>

<%

   Object ex = request.getSession().getAttribute(WebflowHelper.WEBFLOW_EXCEPTION_SESS_ATTR);
   String msg = "";
   String msgKey = "";
   boolean hasErrMsg = true;
   if (null != ex && (ex instanceof Exception)) {
     System.out.println("*** in duplicateContentError.jsp");
     ((Exception)ex).printStackTrace();
     msg = ((Exception) ex).toString();
   }

   if( msg.lastIndexOf("FCCreateDuplicateEntryException") > 0 ||
       msg.lastIndexOf("FCUpdateConflictException") > 0 ||
       msg.lastIndexOf("Duplicate entry") > 0 ) {
     msgKey = "ep.error.duplicate.content.name";
   }
   else if( msg.lastIndexOf("cannot insert NULL") > 0 ) {
     msgKey = "ep.error.missing.required.field.value";
   }
   else if( msg.lastIndexOf("inserted value too large for column") > 0 ) {
     msgKey = "ep.error.too.much.data";
   }
   else {
   //  msg = "An error has occured";
     hasErrMsg = false;
   }

%>

<div class="pageTitle">
  <bean:message key="ep.error.content.publish"/>
</div>

<div class="errorMessage">
  <% if (true == hasErrMsg ) { %>
    <bean:message key="<%= msgKey %>"/>
  <%} %>
</div>

<div>&nbsp;
</div>

<div class="pageButtonWrap" align="right">
  <input type="submit" name="Back" class="pageButton" value="<bean:message key="button.back"/>"
     onClick="try {if(!_click_form_button(this, this.form)) return false;} catch(e) {};next('<%= (String) pageContext.getAttribute("next") %>')"/>

  <input type="submit" name="Cancel" class="pageButton" value="<bean:message key="button.cancel"/>"
     onClick="try {if(!_click_form_button(this, this.form)) return false;} catch(e) {};next('<%= (String) pageContext.getAttribute("cancel") %>')"/>

</div>
